package com.cy.myblog.util;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

/**
 * Created by Administrator on 2015/8/26.
 */
public class treeUtil {
    public static List<Map> treeMenuList(List<Map> menuList, int parentId)
    {
        List<Map> childMenu = new ArrayList<Map>();

        for (Map data : menuList)
        {
            int menuId = Integer.parseInt(String.valueOf(data.get("id")));
            int pid = Integer.parseInt(String.valueOf(data.get("parentId")));
            if ( parentId == pid)
            {
                List childrenNode = treeMenuList(menuList, menuId);
                data.put("childNode", childrenNode);
                childMenu.add(data);
            }
        }

        return childMenu;
    }
}
